﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using Home.Haushalt.Lib;
using Home.Haushalt.Lib.Element;

namespace Home.Haushalt.Gui
{
    static class Program
    {
        #region START ARGS

        public const string STARTARG_PASSWORD = "pass";

        public static Dictionary<string, string> StartArgs = Chips.GetStartArgs(STARTARG_PASSWORD);

        #endregion START ARGS

        /// <summary></summary>
        private static KeyboardHook hook = new KeyboardHook();

        /// <summary></summary>
        internal static Member ClipboardMember;

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);

            hook.KeyPressed += new EventHandler<KeyPressedEventArgs>(hook_KeyPressed);
            hook.RegisterHotKey(ModifierKeys.Control, Keys.D1);
            hook.RegisterHotKey(ModifierKeys.Control, Keys.D2);
            hook.RegisterHotKey(ModifierKeys.Control, Keys.D3);

            Journal.Enabled = true;
            Application.Run(new FrmMain());
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void hook_KeyPressed(object sender, KeyPressedEventArgs e)
        {
            //MessageBox.Show(e.Modifier.ToString() + " + " + e.Key.ToString());
            if (ClipboardMember != default(Member))
            {
                if (e.Modifier.Equals(ModifierKeys.Control))
                {
                    if (e.Key.Equals(Keys.D1))
                    {
                        Clipboard.SetText(ClipboardMember.Row[Member.Fields.Link].ToString());
                    }
                    else if (e.Key.Equals(Keys.D2))
                    {
                        Clipboard.SetText(ClipboardMember.Row[Member.Fields.UserName].ToString());
                    }
                    else if (e.Key.Equals(Keys.D3))
                    {
                        Clipboard.SetText(ClipboardMember.Row[Member.Fields.Pass].ToString());
                    }
                }
            }

        }

    }
}
